<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
	</head>
	<style type="text/css">
		.titles {
			margin-top: 12px;
			margin-left: 10px;
		}
		
		.mui-bar-nav {
			background-color: #222222;
		}
		
		.mui-content>.mui-table-view:first-child {
			margin-top: 5px;
		}
		
		.mui-table-view-cell>a:not(.mui-btn) {
			position: relative;
			display: block;
			overflow: hidden;
			margin: -11px -10px;
			padding: inherit;
			white-space: inherit;
			text-overflow: ellipsis;
			color: inherit;
		}
		
		.mui-table-view .mui-media-object {
			line-height: 25px;
			max-width: 300px;
			height: 25px;
		}
		
		.mui-media-body {
			margin-top: 2px;
			font-size: 0.9em;
			font-weight: bold;
			font-family: "宋体";
		}
	</style>

	<body>
		<script src="js/mui.min.js"></script>
		<script src="js/jquery-1.8.3.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/ServerURL.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			mui.init()
		</script>
		<header class="mui-bar mui-bar-nav">
			<div style="height: 40px; float: left;">
				<a class="mui-action-back mui-icon mui-icon-left-nav"></a>
			</div>
			<div style="height: 40px; float: left;" class="titles"><span class="titless" style="color: white;font-size: 1em;"></span></div>
			<div style="height: 40px; float: right;"></div>
		</header>
		<ul class="mui-table-view" style="margin-top: 50px;">
			<!--
			<li class="mui-table-view-cell mui-media">
				<a href="javascript:;" title="人员名1">
					<img class="mui-media-object mui-pull-left" src="images/user-photo.png">
					<div class="mui-media-body">
						人员名1
					</div>
				</a>
			</li>
			           作者：1471846120@qq.com
            	时间：2018-04-04
            	描述：
            -->
		</ul>
	</body>
	<!--模板先加载-->
	<script type="text/html" id="radio-list">
		<li class="mui-table-view-cell mui-media">
			<a href="javascript:;" title="{{titleID}}">
				<img class="mui-media-object mui-pull-left" src="{{titlesrc}}">
				<div class="mui-media-body">
					{{titleName}}
				</div>
			</a>
		</li>
	</script>
	<script>
		
			var renmainame;
			mui.plusReady(function() {
				//获取传值对象
				var cw = plus.webview.currentWebview();
				renmainame = cw.renmainame;
				//获取对象
				var header = document.querySelector(".titless");
				header.innerText = "搜索企业:" + renmainame;
				 getlist();
			})
			function getlist() {
			LodingListInfo(renmainame);
			mui('.mui-table-view-cell').on("tap", "a", function(e) {
				var title = this.getAttribute("title");
				mui.openWindow({
					url: "contacts_info.html",
					id: "contacts_info.html",
					styles: {
						//top:"40px",//新页面顶部位置
					},
					//打开窗口时传参方法
					extras: {
						titleid: title
					},
					show: {
						autoShow: true,
						aniShow: "slide-in-right",
						duration: 100
					},
					waiting: {
						autoShow: true,
						title: "正在加载中...",
						options: {
							//									width: 
							//									height:
						}
					}
				})
			})
			
		}

		function LodingListInfo(renmainame) {
			mui.ajax({
				type: "post",
				url: ServerURL + '/user/selectByCompany',
				async: false,
				data: {
					"company": renmainame
				},
				dataType: "jsonp",
				jsonp: "jsoncallback",
				timeout: 1000, //超时时间设置为1秒；
				headers: {
					'Content-Type': 'application/json'
				},
				success: function(data, status, xhr) {
					var successString = JSON.parse(data);
					console.log("返回的人脉公司人员数据列表内容为 : " + data);
					var codelog = successString.code;
					//console.log("返回的数据list内容长度为 : " + successString.data.list.length);
					//获取题干模板 
					if(data.indexOf("longitudeLatitude") != -1) {
						var listdata = successString.data.list;
						for(var i = 0; i < listdata.length; i++) {
							tiganStr = $("#radio-list").html();
							//替换相关的字段值 
							tiganStr = del_html_tags(tiganStr, "{{titleID}}", listdata[i].id); //添加题目内容 
							tiganStr = del_html_tags(tiganStr, "{{titleName}}", listdata[i].name); //添加题目显示内容 
							var headImg = listdata[i].headImg;
							if(null != headImg && undefined != headImg) {
								tiganStr = del_html_tags(tiganStr, "{{titlesrc}}", listdata[i].headImg);
							} else {
								tiganStr = del_html_tags(tiganStr, "{{titlesrc}}", "images/weixin.png");
							}
							$(".mui-table-view").append(tiganStr); //替换之后追加到选项中去
						}

					} else if(codelog == "-1") {
						mui.toast('网络连接错误！');
					} else {
						mui.toast('无该公司及企业人员信息！！');
					}
					//plus.nativeUI.closeWaiting();
					return data;
				},
				error: function(xhr, type, errorThrown) {
					console.log("error: " + type);
					return "获取数据失败：服务器错误！";
				}
			});
			//自定义一个方法批量替换制定的字符 
			function del_html_tags(str, reallyDo, replaceWith) {
				var e = new RegExp(reallyDo, "g");
				words = str.replace(e, replaceWith);
				return words;
			}
		}
	</script>

</html>